package cn.hotel.utlis;

import java.util.HashMap;
import java.util.Map;

/**
 * @authorDesc 诸神在上，佑我程序，玄功护体，BUG皆去！
 * @author ZhouJl
 * @date 2022-12-28 10:22:19
 * @version 1.0.0
 * @description 业务逻辑层处理结果返回信息封装类
 */
public class ResultMapUtil {

    /**
     * @description 业务逻辑层正常执行
     * @author ZhouJl
     * @date 2022-12-28 10:23:07
     * @param msg
     * @return {@link Map< String, Object>}
     */
    public static Map<String,Object> success(String msg){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("flag","1");
        resultMap.put("msg",msg);
        return resultMap;
    }

    /**
     * @description 业务逻辑执行失败
     * @author ZhouJl
     * @date 2022-12-28 10:23:17
     * @param msg
     * @return {@link Map< String, Object>}
     */
    public static Map<String,Object> error(String msg){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("flag","0");
        resultMap.put("msg",msg);
        return resultMap;
    }

    /**
     * @description 业务逻辑层发生异常
     * @author ZhouJl
     * @date 2022-12-28 10:23:24
     * @param
     * @return {@link Map< String, Object>}
     */
    public static Map<String,Object> expection(){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("flag","-1");
        resultMap.put("msg","程序错误");
        return resultMap;
    }

    /**
     * @description 自定义返回结果
     * @author ZhouJl
     * @date 2022-12-28 10:23:36
     * @param flag
     * @param msg
     * @return {@link Map< String, Object>}
     */
    public static Map<String,Object> other(String flag,String msg){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("flag",flag);
        resultMap.put("msg",msg);
        return resultMap;
    }
}